package com.manbu.live.user.provider.rpc;

import com.manbu.live.user.dto.UserDTO;
import com.manbu.live.user.inerface.IUserRpc;
import com.manbu.live.user.provider.service.IUserService;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;

/**
 * @author hanWang
 * @Title:
 * @Package
 * @Description:
 * @date 2024/1/87:19 上午
 */
@DubboService
public class IUserRpcImpl implements IUserRpc {

    @Resource
    private IUserService userService;
    @Override
    public String test() {
        System.out.println("this is dubbo test");
        return "SUCCESS";
    }


    public UserDTO getByUserId(Long userId){
        UserDTO byUserId = userService.getByUserId(userId);
        return userService.getByUserId(userId);
    }

    @Override
    public Boolean deleteUserById(Long userId) {

        if (userId == null||userId==0){
            return null;
        }
        return userService.deleteUserById(userId);
    }

    @Override
    public Boolean updateUserById(UserDTO userDTO) {
        if (userDTO == null || userDTO.getUserId() ==null){
            return null;
        }
        return userService.updateUserById(userDTO);
    }

    @Override
    public Boolean saveUser(UserDTO userDTO) {
        if (userDTO == null || userDTO.getUserId() ==null){
            return null;
        }
        return userService.saveUser(userDTO);
    }

    @Override
    public Map<Long, UserDTO> bathQueryUserInfo(List<Long> userIdList) {
        if (CollectionUtils.isEmpty(userIdList)){

        return null;
        }
        return userService.bathQueryUserInfo(userIdList);
    }

}
